package com.atlzk.renting.city.service.impl;

import com.atlzk.common.entity.city.CityEntity;
import com.atlzk.common.utils.PageUtils;
import com.atlzk.common.utils.Query;
import com.atlzk.renting.city.dao.CityDao;
import com.atlzk.renting.city.service.CityService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("cityService")
public class CityServiceImpl extends ServiceImpl<CityDao, CityEntity> implements CityService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<CityEntity> page = this.page(
                new Query<CityEntity>().getPage(params),
                new QueryWrapper<CityEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 省市县  三级联动
     * @param pid
     * @return
     */
    @Override
    public List <CityEntity> findAddress(Integer pid) {
        List <CityEntity> cityEntityList = baseMapper.selectList(new QueryWrapper <CityEntity>().eq("pid", pid));

        return cityEntityList;
    }
}